package com.itheima.service.db.impl;

import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.UmsAdmin;
import com.itheima.domain.UmsAdminRoleRelation;
import com.itheima.mapper.UmsAdminMapper;
import com.itheima.mapper.UmsAdminRoleRelationMapper;
import com.itheima.service.db.UmsAdminService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class UmsAdminServiceImpl implements UmsAdminService {

    @Autowired
    UmsAdminMapper umsAdminMapper;

    @Autowired
    UmsAdminRoleRelationMapper umsAdminRoleRelationMapper;

    //根据用户名查询用户
    @Override
    public UmsAdmin findByOne(String username, String password) {

        LambdaQueryWrapper<UmsAdmin> qw = new LambdaQueryWrapper<>();
        qw.eq(UmsAdmin::getUsername,username).eq(UmsAdmin::getPassword, SecureUtil.md5(password));

        return umsAdminMapper.selectOne(qw);
    }
}
